package com.example.demo.huawei;

public class Main4 {


    public static void main(String[] args) {
//        int count = new Main4().getShanFengCount(new int[]{0, 1, 2, 4, 3, 1, 0, 0, 1, 2, 3, 1, 2, 1, 0});
        int count = new Main4().getShanFengCount(new int[]{0, 1, 2, 3, 2, 4});
        System.out.println(count);
    }


    public int getShanFengCount(int[] arr) {
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if (i == 0) {
                if (arr[i] > arr[i + 1]) {
                    count++;
                }
            } else if (i == arr.length - 1) {
                if (arr[i] > arr[i - 1]) {
                    count++;
                }
            } else if (arr[i] > arr[i + 1] && arr[i] > arr[i - 1]) {
                count++;
            }

        }
        return count;
    }
}
